#include "animationCenter.h"



animationCenter* animationCenter::_aCtr = NULL;
/// singleton method 
animationCenter* animationCenter::getInstance(){
	if (_aCtr == NULL) 
		_aCtr = new animationCenter();
	return _aCtr;
}

animationCenter::animationCenter(){
	
}

void animationCenter::addAnimation(Animable* ani){
	bool bFound = false;
	std::vector<Animable*>::iterator itr;
	Animable* in_ani;
	for(itr = _anis.begin();itr!=_anis.end();itr++){
		in_ani = (*itr);
		if(ani == in_ani)
			bFound = true;
	}

	if(!bFound)
		_anis.push_back(ani);
}

void animationCenter::animate(float avgFrameTime){
	/*分三塊作 , layout , animation , mapping node*/
	this->_avgFrameTime = avgFrameTime;
	std::vector<Animable*>::iterator itr;
	Animable* p;
	for(itr = _anis.begin(); itr!=_anis.end(); itr++){
		p = (*itr);
		p->behavior(avgFrameTime);
	}
}